using ErrorCode;
using MediatR;
using SqlSugar;
using WriteAPI.Command.生产计划;

namespace WriteAPI.CommandHandle.生产计划
{
    public class AddProductionPlanCommandHandler : IRequestHandler<AddProductionPlanCommand, APIResult<int>>
    {
        private readonly ISqlSugarClient _db;

        public AddProductionPlanCommandHandler(ISqlSugarClient db)
        {
            _db = db;
        }

        public async Task<APIResult<int>> Handle(AddProductionPlanCommand request, CancellationToken cancellationToken)
        {
                APIResult<int> result =  new APIResult<int>();
                var id = await _db.Insertable(request.Data).ExecuteReturnIdentityAsync();
                result.Data = id;
                result.Code = 200;
                result.Message = "新增成功";
                return result;
            
            
        }
    }
}

